package metalink.admin;

import com.opensymphony.xwork2.ActionSupport;
import java.util.ArrayList;

import model.admin.GetBatchListMo;
import model.admin.GetCourseListMo;
import model.admin.GetListsMo;
import model.admin.ModifyBatchDetails;
import model.admin.ModifyBatchDetailsMo;
import model.admin.ModifyBatchMo;

	import vo.BatchDetailsVo;
import vo.mixed.CourseListVo;
import vo.mixed.DegreeListVo;

import com.opensymphony.xwork2.ActionSupport;


public class ModifyBatchList extends ActionSupport{
		ArrayList<BatchDetailsVo> batch_list;
		BatchDetailsVo new_batch;
		int batch_id;
		String degree_id;
		int degree_incharge_id;
		String incharge_start_date;
		String incharge_end_date;
		String degree_name;
		String status;
		int degree_management_id;
		String batch_name;
		String start_date;
		String end_date;
		int student_count;
		int start_year;
		int incharge_id;
		String description;
		String edit="";
		String update="";
		String delete="";
		String value="";
		ArrayList<String> course_list;
		ArrayList< DegreeListVo> degree_list = new ArrayList<DegreeListVo>();

		public String execute() throws Exception {
			GetBatchListMo mo = new GetBatchListMo();
			ModifyBatchDetailsMo modifymo= new ModifyBatchDetailsMo();
			if(edit.contentEquals("yes")){
				batch_list=mo.editbatchlist(batch_id);
			}else if (update.contentEquals("yes")){
				modifymo.editBatchDetails(batch_id, batch_name, start_date, end_date, student_count, start_year, incharge_id, description,update);
				batch_list=mo.getBatchList();
			}else if(delete.contentEquals("yes")){
				modifymo.deleteBatchDetails(batch_id,delete);
				batch_list=mo.getBatchList();
			}else if(value.contentEquals("editbatchdegree")){
				degree_list=mo.editBatchDegree(Integer.parseInt(degree_id),batch_id);
			}
			degree_list=mo.getAddBatchDegree(batch_id);
			return SUCCESS;
		}

		public String submitNewBatch() throws Exception {
			GetBatchListMo BatchListObject= new GetBatchListMo();
			setBatch_list(BatchListObject.getBatchList());
			
			
			BatchDetailsVo newBatch = new BatchDetailsVo();
			newBatch.setBatch_name(getBatch_name());
			newBatch.setDescription(getDescription());
			newBatch.setIncharge_id(getIncharge_id());
			newBatch.setEnd_date(getEnd_date());
			newBatch.setStart_date(getStart_date());
			newBatch.setStart_year(getStart_year());
			newBatch.setStudent_count(getStudent_count());

			ModifyBatchDetails new_object = new ModifyBatchDetails();
			int res=new_object.addBatchDetails(newBatch,"AddBatchDetails");
			if(res==1)
			return SUCCESS;
			else return ERROR;
		}
		public String editBatchDetails() throws Exception
		{
			
			return SUCCESS;
		}
		public String deleteBatchDetails() throws Exception{
			ModifyBatchDetails deleteObj = new ModifyBatchDetails();
			if(deleteObj.deleteBatchDetails(batch_id,"DeleteBatch")==1)			
			return SUCCESS;
			else return ERROR;
		}
public String addNewBatchCourse() {
	
	GetListsMo listCourses= new GetListsMo();
	setCourse_list(listCourses.getCourseList(batch_id,0,0));
	
	return SUCCESS;
}

public String getDegree_id() {
	return degree_id;
}

public void setDegree_id(String degree_id) {
	this.degree_id = degree_id;
}

public int getDegree_incharge_id() {
	return degree_incharge_id;
}

public void setDegree_incharge_id(int degree_incharge_id) {
	this.degree_incharge_id = degree_incharge_id;
}

public String getIncharge_start_date() {
	return incharge_start_date;
}

public void setIncharge_start_date(String incharge_start_date) {
	this.incharge_start_date = incharge_start_date;
}

public String getIncharge_end_date() {
	return incharge_end_date;
}

public void setIncharge_end_date(String incharge_end_date) {
	this.incharge_end_date = incharge_end_date;
}

public String getDegree_name() {
	return degree_name;
}

public void setDegree_name(String degree_name) {
	this.degree_name = degree_name;
}

public String getStatus() {
	return status;
}

public void setStatus(String status) {
	this.status = status;
}

public int getDegree_management_id() {
	return degree_management_id;
}

public void setDegree_management_id(int degree_management_id) {
	this.degree_management_id = degree_management_id;
}

public String getValue() {
	return value;
}

public void setValue(String value) {
	this.value = value;
}

public ArrayList<DegreeListVo> getDegree_list() {
	return degree_list;
}

public void setDegree_list(ArrayList<DegreeListVo> degree_list) {
	this.degree_list = degree_list;
}

public String getDelete() {
	return delete;
}

public void setDelete(String delete) {
	this.delete = delete;
}

public String getEdit() {
	return edit;
}

public void setEdit(String edit) {
	this.edit = edit;
}

public String getUpdate() {
	return update;
}

public void setUpdate(String update) {
	this.update = update;
}

public ArrayList<String> getCourse_list() {
	return course_list;
}

public void setCourse_list(ArrayList<String> course_list) {
	this.course_list = course_list;
}

public ArrayList<BatchDetailsVo> getBatch_list() {
	return batch_list;
}

public void setBatch_list(ArrayList<BatchDetailsVo> batch_list) {
	this.batch_list = batch_list;
}



public BatchDetailsVo getNew_batch() {
	return new_batch;
}

public void setNew_batch(BatchDetailsVo new_batch) {
	this.new_batch = new_batch;
}

public int getBatch_id() {
	return batch_id;
}

public void setBatch_id(int batch_id) {
	this.batch_id = batch_id;
}

public String getBatch_name() {
	return batch_name;
}

public void setBatch_name(String batch_name) {
	this.batch_name = batch_name;
}

public String getStart_date() {
	return start_date;
}

public void setStart_date(String start_date) {
	this.start_date = start_date;
}

public String getEnd_date() {
	return end_date;
}

public void setEnd_date(String end_date) {
	this.end_date = end_date;
}

public int getStudent_count() {
	return student_count;
}

public void setStudent_count(int student_count) {
	this.student_count = student_count;
}

public int getStart_year() {
	return start_year;
}

public void setStart_year(int start_year) {
	this.start_year = start_year;
}

public int getIncharge_id() {
	return incharge_id;
}

public void setIncharge_id(int incharge_id) {
	this.incharge_id = incharge_id;
}

public String getDescription() {
	return description;
}

public void setDescription(String description) {
	this.description = description;
}
}

